require("../../assets/fonts/iconfont.css");
require("../../assets/css/normalize.css");
require("../../assets/css/reset.css");
require("./login.less");

//引入模块
const CaptchaMini = require("captcha-mini");
const dom = require("../../utils/dom");
const axios = require("axios");
console.log(dom);
document.addEventListener("DOMContentLoaded", function () {
	dom.get("#btn").addEventListener("click", async function () {
		let tel = dom.get("#tel").value;
		let pasw = dom.get("#pasw").value;
		//axios通过验证，发送请求
		let returnCode = await axios.post(
			"http://fitness.h5.itsource.cn:3701/api/user/login",
			{
				account: tel,
				password: pasw,
			}
		);
		if (returnCode.data.errno === 0) {
			localStorage.setItem("token", returnCode.data.data.token);
			// console.log("打印", returnCode.data.data.token);
			location.href = "index.html";
			alert("登录成功,赶快运动起来8!!");
		} else {
			alert("糟糕登录失败," + returnCode.data.message);
		}
	});
});

//
